﻿
namespace Patterns4Net.PatternEnforcer.Core.Patterns
{
    using System.ComponentModel.Composition;
    using Patterns4Net.Attributes;

    /// <summary>
    /// Provides location of pattern checkers base on implementation 
    /// of the <see cref="IPatternCheckerProvider"/> interface.
    /// </summary>
    [Export(typeof(IPatternCheckersLocator))]
    public class PatternCheckerProviderLocator : IPatternCheckersLocator
    {
        public IPatternChecker GetCheckerFor(IPattern patternBase)
        {
            if (patternBase is IPatternCheckerProvider)
            {
                return ((IPatternCheckerProvider)patternBase).GetChecker();
            }

            return null;
        }
    }
}
